<template>
    <div class="sysm-body zfbazd-index">
        <a href="javasctipt:;" v-if="isShowBack" @click.stop="toRouter('zd')" class="zhsf-btn-box" style="position: absolute; top: 50px; left: 20px;padding:0 20px;z-index:2;">首页</a>
        <a href="javasctipt:;" v-if="isShowBack" @click.stop="toRouter('zd')" class="zhsf-btn-box" style="position: absolute; top: 50px; left: 130px;padding:0 20px;z-index:2;">返回</a>
        <!-- <div :class="isIndexPage ? 'sysm-b-header children-page' : 'sysm-b-header' "> -->
        <div class="sysm-b-header">
            <h1 @click.stop="toRouter('zd')"></h1>
            <div class="sysm-bh-right">
                <span>{{time}}</span>
                <i class="sysm-bhright-day">{{day}}</i>
                <i class="sysm-bhright-week">{{weekday}}</i>
            </div>
        </div>

        <router-view></router-view>
    </div>
</template>

<script>
import {} from '@/utils'
export default {
    data(){
        return {
            isShowBack : false,
            isIndexPage : false,
            routeName : "zd",
            time:'',
            day:'',
            weekday:'',
            weekdays:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
        }
    },
    created(){
        setInterval(this.setTime,1000);
    },
    methods:{
        toRouter(o){
            // console.log(o);
            this.routeName = o;
            if(o != 'zd' ){
                
                this.isShowBack = true;
            }
            this.vtp.toRouter(this,o);
        },
        setTime(){
            var date = new Date();
            this.weekday=this.weekdays[date.getDay()];
            this.day=this.PrefixZero((date.getMonth() + 1),2)+'-'+this.PrefixZero(date.getDate(),2);
            this.time = this.PrefixZero(date.getHours(),2)+":"+this.PrefixZero(date.getMinutes(),2);
        },
        PrefixZero(num, n){
            return (Array(n).join(0) + num).slice(-n);
        }
    },
    watch:{
        routeName(){
            if(this.routeName != 'zd' ){
                this.isShowBack = true;
            }
        }
    }
}
</script>

<style>
    h1{margin: 0;padding: 0;}
</style>